<#include "/admin/_inc/_head.html"/>
<#include "/admin/_inc/_layout.html" />
<!DOCTYPE html>
<html lang="en">

<head>
    <@head />
</head>

<body>
<@layout>
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>
                        <small></small>
                    </h5>

                </div>
                <div class="ibox-content">
                    <form id="form" action="<#if model?exists>${ctx_admin}/wx-account/update<#else>${ctx_admin}/wx-account/add</#if>"
                          method="post" class="form form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">公众帐号名称</label>
                            <div class="col-sm-10">
                                <input type="hidden" name="id" value="${model.id}">
                                <input type="text" class="form-control" placeholder="" name="name" required=""
                                       aria-required="true" value="${model.name}">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">公众微信号</label>
                            <div class="col-sm-10">
                                <input name="code" type="text" class="form-control" required="" aria-required="true"
                                       value="${model.code}">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">URL(不需要填写)</label>
                            <div class="col-sm-10">
                                <input name="url" type="text" class="form-control" required="" aria-required="true"
                                       readonly value="${model.url}">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">公众帐号TOKEN：</label>
                            <div class="col-sm-10">
                                <input type="text" placeholder="" class="form-control" required="" aria-required="true"
                                       name="token"
                                       value="${model.token}">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">公众号类型：</label>
                            <div class="col-sm-10">
                                <input id="h_sex" type="hidden" value="${model.stype}">
                                <span class="select-box" style="width:150px;">
                                <select id="stype" name="stype" size="1" class="form-control" required=""
                                        aria-required="true">
                                    <option value="1">服务号</option>
                                    <option value="2">订阅号</option>
                                    <option value="3">企业号</option>
                                </select>
                                </span>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">公众帐号邮箱：</label>
                            <div class="col-sm-10">
                                <input type="text" placeholder="" class="form-control" required="" aria-required="true"
                                       name="email" value="${model.email}">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">公众帐号APPID：</label>
                            <div class="col-sm-10">
                                <input type="text" placeholder="" class="form-control" required="" aria-required="true"
                                       name="appid" value="${model.appid}">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">公众帐号APPSECRET：</label>
                            <div class="col-sm-10">
                                <input type="text" placeholder="" class="form-control" required="" aria-required="true"
                                       name="appsecret" value="${model.appsecret}">
                            </div>
                        </div>


                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">公众帐号描述：</label>
                            <div class="col-sm-10">
                                <textarea name="description" cols="" rows="" class="form-control" required=""
                                          aria-required="true"
                                          placeholder="说点什么...100个字符以内">${model.description}</textarea>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>


</@layout>

<script src="/assets/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/assets/js/plugins/validate/messages_zh.min.js"></script>
<script src="/assets/js/plugins/jquery.form/jquery.form.js"></script>
<script type="text/javascript">
    $(function () {

        $("#form").validate({
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    url: form.action,
                    dataType: 'json',
                    success: function (res) {
                        if (res.success) {
                            layer.msg(res.message, {icon: 1, time: 2000}, function () {
                                location.reload();
                            });
                        } else {
                            layer.msg(res.message, {icon: 2, time: 3000}, function () {
                            });
                        }
                    },
                    error: function () {
                        layer.msg('系统错误', {icon: 2, time: 3000}, function () {
                        });
                    }
                });
            }
        });

    });
</script>

</body>

</html>